<template>
  <div class="login-container">
    <div class="form">
      <div class="form__body" v-show="display">
        <div class="form__group">
          <label class="form__label">科室号</label>
          <input type="text" v-model="depcode" class="form__input" placeholder="请输入科室编号" required>
        </div>
        <button class="form__button" @click="handleLogin">登录</button>
        <button class="form__button" @click="handleSwitch">切换</button>
      </div>
      <div class="form__body" v-show="!display">
        <div class="form__group">
          <label class="form__label">药库号</label>
          <input type="text" v-model="drugstoreId" class="form__input" placeholder="请输入药库编号" required>
        </div>
        <button class="form__button" @click="handleLogin">登录</button>
        <button class="form__button" @click="handleSwitch">切换</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "LoginIndex",
  data(){
    return{
      depcode:'',
      drugstoreId:null,
      display:true
    }
  },
  created() {

  },
  methods:{
    handleLogin(){
      if (this.display){//科室显示屏
        this.$store.commit("updateDepcode",this.depcode)
        this.$router.push({path:'/home',query:{depcode:this.depcode}})
      }else{
        this.$router.push({path:'/drugstore',query:{drugstoreId:this.drugstoreId}})
      }

    },
    handleSwitch(){
      this.display=!this.display
    }
  }
}
</script>

<style lang="less" scoped>
.form {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;

  &__title {
    text-align: center;
    margin-bottom: 20px;
  }

  &__body {
    background-color: #f9f9f9;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    width: 300px;

    & .form__group {
      margin-bottom: 20px;

      & .form__label {
        display: block;
        font-weight: bold;
        margin-bottom: 5px;
      }

      & .form__input {
        width: 100%;
        padding: 10px;
        border: none;
        border-radius: 5px;
        box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);

        &:focus {
          outline: none;
        }
      }
    }

    & .form__button {
      display: block;
      width: 100%;
      background-color: #008CBA;
      color: #fff;
      padding: 10px;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      margin-bottom: 10px;

      &:hover {
        background-color: #006F8A;
      }
    }
  }
}

</style>